using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShopDetection : MonoBehaviour
{
    [SerializeField] private GameObject tip;
    
    private bool isCanOpenShop = false;

    private void Update()
    {
        if(!isCanOpenShop)
            return;

        if (PlayerInput.Instance.GetIsInteraction)
        {
            UIManager.Instance.OpenPanel(UIConst.SHOP);
        }
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        // 检测玩家
        if (other != null && other.CompareTag("Player"))
        {
            tip.gameObject.SetActive(true);
            isCanOpenShop = true;
        }
    }

    private void OnTriggerExit2D(Collider2D other)
    {
        if (other != null && other.CompareTag("Player"))
        {
            tip.gameObject.SetActive(false);
            isCanOpenShop = false;
        }
    }
}
